From 3345df5b535f04f2e59bb505cfb89438897c1bfe Mon Sep 17 00:00:00 2001 From: debris Date: Tue, 2 Feb 2016 11:30:28 +0100 Subject: [PATCH] fixed cargo bench --no-run --- src/cargo/ops/cargo_test.rs | 4 ++++ tests/test_cargo_bench.rs | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/cargo/ops/cargo_test.rs b/src/cargo/ops/cargo_test.rs index d07b4bbae..55a9ec5f0 100644 --- a/src/cargo/ops/cargo_test.rs +++ b/src/cargo/ops/cargo_test.rs @@ -50,6 +50,10 @@ pub fn run_benches(manifest_path: &Path, let mut args = args.to_vec(); args.push("--bench".to_string()); let compilation = try!(compile_tests(manifest_path, options)); + + if options.no_run { + return Ok(None) + } let errors = try!(run_unit_tests(options, &args, &compilation)); match errors.len() { 0 => Ok(None), diff --git a/tests/test_cargo_bench.rs b/tests/test_cargo_bench.rs index fe815d657..737618629 100644 --- a/tests/test_cargo_bench.rs +++ b/tests/test_cargo_bench.rs @@ -922,6 +922,35 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured ", compiling = COMPILING, running = RUNNING))); }); +test!(test_bench_no_run { + if !::is_nightly() { return } + + let p = project("foo") + .file("Cargo.toml", r#" + [project] + name = "foo" + authors = [] + version = "0.1.0" + "#) + .file("src/lib.rs", "") + .file("benches/bbaz.rs", r#" + #![feature(test)] + + extern crate test; + + use test::Bencher; + + #[bench] + fn bench_baz(_: &mut Bencher) {} + "#); + + assert_that(p.cargo_process("bench").arg("--no-run"), + execs().with_status(0) + .with_stdout(&format!("\ +{compiling} foo v0.1.0 ([..]) +", compiling = COMPILING))); +}); + test!(test_bench_multiple_packages { if !::is_nightly() { return } -- 2.30.2